﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DetectUsbSpeed
{
    class Program
    {
        static void Main(string[] args)
        {
            var hostCtrls = USB.GetHostControllers();

            foreach (var hostCtrl in hostCtrls)
            {
                var hub = hostCtrl.GetRootHub();
                foreach (var port in hub.GetPorts())
                {
                    if (port.IsDeviceConnected && !port.IsHub)
                    {
                        var device = port.GetDevice();
                        Console.WriteLine("Serial: " + device.DeviceSerialNumber);
                        Console.WriteLine(string.Format("Device Name: {0} {1}", device.Manufacturer, device.Product));
                        Console.WriteLine("Speed:  " + port.Speed);
                        Console.WriteLine("Port:   " + device.PortNumber + Environment.NewLine);
                    }
                }
            }
        }
    }
}
